/*
  初始化

  线程都需要在此处配置任务句柄 队列ID等等 
  要在user_task.h中定义一系列参数 其中各个线程的属性在user_task.c中定

*/

/* Includes ----------------------------------------------------------------- */
#include "bmi088.h"
#include "user_task.h"
#include "can_use.h"
#include "cmd.h"
#include "Action.h"

/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
/* Private function --------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */

/**
 * \brief 初始 在此函数中可以初始化任务，队列，信号量等，初始化完成后，自己删除自己
 *
 * \param argument 未使用参数传递
 */
void Task_Init(void *argument) {
  (void)argument; 
  
//  task_runtime.config = Config_ChassisGet();
//  osKernelLock();
  /* 任务*/
  task_runtime.thread.atti_esti =
      osThreadNew(Task_AttiEsti, NULL, &attr_atti_esti);
//	task_runtime.thread.chassis =
//      osThreadNew(Task_Chassis, NULL, &attr_chassis);
//	task_runtime.thread.navi =
//      osThreadNew(Task_Navi, NULL, &attr_navi);
//  task_runtime.thread.r12ds =
//      osThreadNew(Task_r12ds,NULL,&attr_r12ds);
//  task_runtime.thread.can =
//      osThreadNew(Task_can,NULL,&attr_can);
//  task_runtime.thread.action =
//      osThreadNew(Task_action,NULL,&attr_action);
//  task_runtime.thread.cmd =
//      osThreadNew(Task_cmd,NULL,&attr_cmd);
//   task_runtime.thread.nuc =
//      osThreadNew(Task_nuc,NULL,&attr_nuc); 

  /* 消息队列 */
    /* can */
//  task_runtime.msgq.can.feedback.chassisfed6020 =
//      osMessageQueueNew(2u, sizeof(CAN_t), NULL);
//  task_runtime.msgq.can.output.chassis6020 =
//      osMessageQueueNew(2u, sizeof(CAN_DJIOutput_t), NULL);
//			
//	task_runtime.msgq.can.feedback.chassisfed5065 =
//      osMessageQueueNew(2u, sizeof(CAN_t), NULL);
//  task_runtime.msgq.can.output.chassis5065 =
//      osMessageQueueNew(2u, sizeof(CAN_VescOutput_t), NULL);


	/* imu */
   task_runtime.msgq.imu.accl =
      osMessageQueueNew(2u, sizeof(AHRS_Accl_t), NULL);
  task_runtime.msgq.imu.eulr =
     osMessageQueueNew(2u, sizeof(AHRS_Eulr_t), NULL);
  task_runtime.msgq.imu.gyro =
      osMessageQueueNew(2u, sizeof(AHRS_Gyro_t), NULL);
	
			
		/*cmd */
//   task_runtime.msgq.cmd.raw.rc =
//      osMessageQueueNew(3u, sizeof(CMD_RC_t), NULL);
//	 task_runtime.msgq.cmd.chassis =
//	    osMessageQueueNew(3u, sizeof(CMD_t), NULL);
//	 task_runtime.msgq.cmd.raw.ops_9pos =
//      osMessageQueueNew(3u, sizeof(Action_POS_t), NULL);
//   task_runtime.msgq.cmd.raw.ops_9 = 
//      osMessageQueueNew(3u,sizeof(CMD_ACTION_t),  NULL);
//   task_runtime.msgq.cmd.raw.nuc =
//      osMessageQueueNew(3u,sizeof(CMD_NUC_t), NULL);

//	task_runtime.mutex.imu_eulr = 
//			xSemaphoreCreateMutex();

  osKernelUnlock();
  osThreadTerminate(osThreadGetId()); /* 结束自身 */
}
